﻿@*
    编辑模板
*@

@using NewLife;
@using System.Reflection
@using XCode
@using XCode.Configuration
@using Microsoft.AspNetCore.Mvc.Rendering;
@{
    var entity = Model as IEntity;
    var isNew = entity.IsNullKey;
    var fields = ViewBag.Fields as FieldCollection;

    var url = "";
    var rv = entity.GetRouteKey();
    if (rv != null && rv.Count > 0)
    {
        url = Url.Action(isNew ? "Add" : "Edit", rv);
    }

    else
    {
        url = Url.Action(isNew ? "Add" : "Edit");
    }

    Object htmlAttributes = null;
    if (fields.Any(e => e.ItemType.EqualIgnoreCase("file", "image"))) htmlAttributes = new { enctype = "multipart/form-data" };
}

<!-- 表单仪表盘，用于显示实体对象的统计信息 -->
@await Html.PartialAsync("_Form_Dashboard", entity)

<!--模板表单-->
@using (Html.BeginForm("Edit", null, rv, FormMethod.Post, null, htmlAttributes))
{
    <div class="card">

        @await Html.PartialAsync("_Form_Header", entity)
        @await Html.PartialAsync("_Form_Body", entity)
        @await Html.PartialAsync("_Form_Footer", entity)
        @*@await Html.PartialAsync("_Form_Action", entity)*@

    </div>
}